package com.zlt.dao;

import com.zlt.pojo.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.mapstruct.Mapper;

import java.util.List;

@Mapper
public interface IUserDao {

    @Select("select * from users where username = #{username}")
     List<User> findByName(String name);

    @Select("insert into users(id, username, password) values(#{id},#{username},#{password})")
     String add(User user);

    @Delete("delete from users where id = #{id}")
     int del(int id);

    @Update("update users set password = #{password}")
     int edit(User user);

    @Select("select * from users where id = #{id}")
     User select(int id);

    @Select("select count(*) from users ")
     int getTotal();

    @Select("select * from users limit #{pageNum},10")  //limit 后面不允许加上运算，在传入参数时需要先将运算完成
     List<User> findByPage(int pageNum);
}
